package com.chapter.sample.juc.locks;

import java.util.concurrent.TimeUnit;

public class DeadLockDemo {

    static Object lockA = new Object();
    static Object lockB = new Object();

    public static void main(String[] args) throws Exception {
        new Thread(()->{
            synchronized (lockA){
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (lockB){}
            }
        },"a").start();
        new Thread(()->{
            synchronized (lockB){
                synchronized (lockA){}
            }
        },"b").start();
    }
}
